<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/20
 * Time: 16:20
 */

$str = '$data[\'username\']=10';
//$str = '$data[123]=10';
//var_dump($str);


if (preg_match('/^\$data\[\'(\w+)\'\]=(\d+)/',$str,$m)){
    echo 'yes';
    var_dump($m);
} else {
    echo "no";
    var_dump($m);
}

